public class Solution1009 {
    public int bitwiseComplement(int n) {
        if (n==0){
            return 1;
        }
        long t=1;
        while (t<=n){
            t=t*2;
        }
        return (int)t-n-1;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1009().bitwiseComplement(10));
    }
}
